CMAKE_MINIMUM_REQUIRED (VERSION 3.7.2)
project("XY")

SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../APP/${CMAKE_BUILD_TYPE})

IF(DEFINED ENV{QT_DIR})
	set(Qt5Core_DIR "$ENV{QT_DIR}/lib/cmake/Qt5Core")
	set(Qt5_DIR "$ENV{QT_DIR}/lib/cmake/Qt5")
	set(QT_QMAKE_EXECUTABLE "$ENV{QT_DIR}/bin/qmake.exe")
ENDIF()

FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5OpenGL REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS})


SET(CMAKE_AUTOMOC ON)   # 设置自动生成moc文件,AUTOMOC打开可以省去QT5_WRAP_CPP命令
SET(CMAKE_AUTOUIC ON)	# 设置自动生成ui.h文件,AUTOUIC打开可以省去QT5_WRAP_UI命令
SET(CMAKE_AUTORCC ON)

SET(EXE_NAME XYCreat)
INCLUDE_DIRECTORIES(src/Widgets)
INCLUDE_DIRECTORIES(3d-part/qcustomplot)
#AUX_SOURCE_DIRECTORY(. DIR_SRCS )

# 查找当前文件夹中的所有相关文件
FILE(GLOB W3CPP "src/Widgets/*.cpp")
FILE(GLOB MAIN_CPP "*.cpp")
FILE(GLOB HEADER_FILES "src/Widgets/*.h")
#FILE(GLOB PLOT_UI_FILES  "src/Widgets/MultPlot.ui")

#QT5_WRAP_UI(WRAP_UI ${PLOT_UI_FILES} )

SET(CUS_PLOT
		3d-part/qcustomplot/qcustomplot.h
		3d-part/qcustomplot/qcustomplot.cpp
		)

SET(UI_FILES
		mainwindow.ui
		src/Widgets/MultPlot.ui)

ADD_EXECUTABLE(${EXE_NAME}
		${W3CPP}
		${CUS_PLOT}
		${MAIN_CPP}
		${HEADER_FILES}
		${WRAP_UI}
		${UI_FILES}
		)

target_link_libraries(${EXE_NAME}
		Qt5::Core
		Qt5::Gui
		Qt5::Widgets
		Qt5::PrintSupport
		Qt5::OpenGL)

#set_target_properties(${EXE_NAME}  PROPERTIES DEBUG_POSTFIX "d")
